package com.jeesite.modules;

/**
 * Created by chensk on 2018/4/15.
 */

import com.itextpdf.text.BaseColor;
import com.itextpdf.text.DocumentException;
import com.itextpdf.text.Font;
import com.itextpdf.text.FontProvider;
import com.itextpdf.text.pdf.BaseFont;

import java.io.IOException;

/**支持中文*/
public final class ChinaFontProvide implements FontProvider {

    @Override
    public Font getFont(final String fontname, final String encoding, final boolean embedded, final float size, final int style, final BaseColor color) {


        BaseFont bf = null;

        try {
             bf = BaseFont.createFont("/fangsong.ttf",BaseFont.IDENTITY_H,BaseFont.EMBEDDED);

        } catch (Exception e) {
            e.printStackTrace();
        }
        Font font = new Font(bf, size, style, color);
      //  font.setStyle("underline");
      // font.setStyle( Font.FontStyle.UNDERLINE);
        font.setColor(color);

        return font;

    }

    @Override
    public boolean isRegistered(String arg0) {
        return false;
    }
}